@file:Suppress("UNCHECKED_CAST")

package com.benin.sms.extipetrpide

import android.content.Intent
import com.benin.sms.base.BaseActivity

inline fun <reified T> BaseActivity.startToNextActivity(params: HashMap<String, String>) {
    try {
        val intent = Intent(this, T::class.java)
        params.keys.forEach { gkey ->
            intent.putExtra(gkey, params[gkey])
        }
        startActivity(intent)
    } catch (e: Exception) {
        e.printStackTrace()
    }
}

inline fun <reified T> BaseActivity.startToNextActivityAndFinish(params: HashMap<String, String> = HashMap()) {
    try {
        val intent = Intent(this, T::class.java)
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_SINGLE_TOP)
        params.keys.forEach { gkey ->
            intent.putExtra(gkey, params[gkey])
        }
        startActivity(intent)
//        finish()
    } catch (e: Exception) {
        e.printStackTrace()
    }
}